﻿using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UCS.XNA.Utils.Math
{
    public static class GeometricAlgebra
    {
        public static double GetAngleBetweenVectors(Vector2 vectorA, Vector2 vectorB)
        {
            var pos = new Vector2(vectorB.X - vectorA.X, vectorB.Y - vectorA.Y);
            var ang = System.Math.Atan2(pos.X, pos.Y);
            return ang * -1;
        }

        public static Vector2 RotateVector(Vector2 vector, float angle, Vector2 origin)
        {
            //angle *= -1;
            var onOrigin = vector - origin;
            var ang = System.Math.Atan2(onOrigin.Y, onOrigin.X) + angle;
            var sin = System.Math.Sin(ang);
            var cos = System.Math.Cos(ang);

            var result = new Vector2((float)cos, (float)sin) * onOrigin.Length();
            return result + origin;
        }
    }
}
